import {Injectable} from '@angular/core';
import {SERVERS_NAME} from '../../../config/config';
import {HttpService} from '../../../core/http.service';
import {CommHttpService} from '../../../core/comm.http.service';

@Injectable()
export class TeacherService extends CommHttpService {


  protected preUrl = `${SERVERS_NAME.SECURITY_SERVER}sys/teacher/`;

  constructor(protected http: HttpService) {
    super(http);
  }

  /**
   * 查询部门
   */
  getDepartment() {
    return this.http.get({}, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/dept/list');
  }

  /**
   * 编辑
   */
  update(data) {
    return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/teacher/update');
  }

  /**
   * 删除
   */
  delete(arr) {
    return this.http.post(arr, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/teacher/delete');
  }

  /**
   * 查询职务/职称
   */
  positionList(param) {
    return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/dictionary/listByType/' + param);
  }

  /**
   * 查询职务/职称/任职类型 --- 过滤时使用
   */
  threeList(param) {
    return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/dictionary/listFilter/' + param);
  }

  /**
   * 查询权限
   * @param id user.id
   * @returns {Observable<any>} 返回值
   */
  getRole(ids) {
    return this.http.post({id: ids}, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/role/showAuth');
  }

  /**
   * 保存分配的权限
   * @param data data
   * @returns {Observable<any>} 返回值
   */
  saveRole(data) {
    return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/role/userAuth');
  }

  /**
   * 重置密码
   * @ param data da
   */
  resetPassword(ids) {
    return this.http.post({id: ids}, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/user/resetPassword');
  }

  /**
   * 导出Excel
   *
   * @param data data
   * @returns {Observable<any>} 返回值
   */
  exportExcel(data) {
    return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/teacher/exportExcel');
  }

  /**
   * 导入Excel
   *
   * @param fileId Excel文件id
   * @returns {Observable<any>} 返回值
   */
  importExcel(data) {
    return this.http.postFile(data, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/teacher/importExcel');
  }
}
